<script type="text/javascript">
//<![CDATA[
    function sendMail(){
		with(document.frmReg){
			//alert('메일 전송 구현할것');
			submit();
		}
    }

    function mailPreview(){
        window.open("","WIN_PREVIEW","width=800,height=800");
        with(document.frmReg){
			target = "WIN_PREVIEW";
			action="/mail/mailPreview";
			submit();
        }
    }
    
	$(function(){
		/*$("[name=template]").change(function(){
			with(document.frmReg){
				submit();
			}
		});*/

		//이메일
		$("[name=domain_support]").change(function(){
			if($(this).val()){
				$("[name=mail_domain]").attr("readonly",true);
				$("[name=mail_domain]").val($(this).val());
			}else{
				$("[name=mail_domain]").attr("readonly",false);
				$("[name=mail_domain]").val('');
				$("[name=mail_domain]").focus();
			}
		});

		//대상자
		$("[name=target]").click(function(){
			if($(this).val()=="manual"){//직접입력
				$("[name=mail_id]").attr("disabled",false);
				$("[name=mail_domain]").attr("disabled",false);
				$("[name=domain_support]").attr("disabled",false);
			}else{
				$("[name=mail_id]").attr("disabled",true);
				$("[name=mail_domain]").attr("disabled",true);
				$("[name=domain_support]").attr("disabled",true);
			}
		});
	});
//]]>
</script>
<div class="box_type02">
<h2 class="txt">메일관리</h2>
<p class="icon"><a href="javascript:void(0);" class="icon_m04">매뉴얼</a></p>

<!--[s] 쓰기 -->
<form name="frmReg" method="post" action="/mail/mailSend">
<fieldset class="board_write">
	<legend>메일관리</legend>
	<table cellspacing="0" summary="메일관리" class="lines">
		<caption>메일관리</caption>
		<tr>
			<th scope="row" rowspan="3" width="140" class="vat"><label for="title" class="point">수신자</label></th>
			<td>
				<div>
					<input type="radio" id="" name="target" class="ip_c" checked="checked" value="total" /><label for="" class="txt_type01">회원전체 (<strong class="cff5400"><?php echo $target['total'];?></strong>)</label>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<div><input type="radio" id="" name="target" class="ip_c" value="birthday" /><label for="" class="txt_type01">금일 생일자 (<strong class="cff5400"><?php echo $target['birthday'];?></strong>)</label></div>
			</td>
		</tr>
		<tr>
			<td>
				<div>
					<input type="radio" id="" name="target" class="ip_c" value="manual" /><label for="" class="txt_type01">직접입력 </label>
					<input type="text" id="" name="mail_id" class="ip_i" style="width:155px;" value="" disabled />
					<span class="txt_type01">@</span>
					<input type="text" id="" name="mail_domain" class="ip_i" style="width:155px;" value="" disabled />
					<select name="domain_support" class="ip_s ml6" style="width:130px;" disabled>
						<option value="">직접입력</option>
						<?php 
							foreach($this->config->item('ch_mail_domain') as $key){
								$selected = ($key == $mail_domain) ? 'selected' :'';
								echo "<option value=\"{$key}\" {$selected}>{$key}</option>\n";
							}
						?>
					</select>
				</div>
			</td>
		</tr>
		<tr>
			<th scope="row"><label for="title" class="point">제목</label></th>
			<td>
				<div><input type="text" id="title" name="title" class="ip_i" style="width:584px;" value="<?php echo set_value('title')?>" /></div>
			</td>
		</tr>
		<tr>
			<th scope="row" class="vat"><p class="point">메일폼</p></th>
			<td>
				<div>
					<p class="mb5">
						<select name="template" class="ip_s" style="width:130px;">
							<option value="">직접입력</option>
							<?php 
								foreach($template_list as $item){
									
									echo "<option value=\"{$item}\" ".set_select('template', $item).">{$item}</option>\n";
								}
							?>
						</select>
					</p>
					<textarea id="textarea_id" name="content" rows="" cols="" class="ip_t"><?php echo set_value('content')?></textarea>
					<script type="text/javascript" src="/asset/ckeditor/ckeditor.js"></script>
					<script type="text/javascript">
						CKEDITOR.replace('textarea_id',{
						      filebrowserImageUploadUrl:"/asset/ckeditor/upload.php?type=Images"
						 });				   
					</script>
				</div>
			</td>
		</tr>
	</table>
</fieldset>
</form>
<!--[e] 쓰기 -->

<!-- [s] 버튼 -->
<ul class="botton_box mt30">
	<li class="center">
		<a href="javascript:sendMail();"><img src="/theme/<?=$_theme?>/images/common/btn_send.gif" alt="전송" /></a>
		<a href="javascript:history.back();"><img src="/theme/<?=$_theme?>/images/common/btn_cancel.gif" alt="취소" /></a>
		<input type="button" value="미리보기" onclick="mailPreview();" />
	</li>
</ul>
<!-- [e] 버튼 -->

<!--[s] Tip -->
<dl id="tip" class="mt30">
	<dt>Tip</dt>
	<dd>인터넷익스플로러의 '호환성보기' 기능을 사용중인 접속자에게 자동으로 최신버전 기준으로 사이트를 출력하도록 처리합니다.</dd>
	<dd>코딩방식에 따라 특정 버전의 브라우저에서 사이트가 깨질수 있으니, 충분한 테스트 후 기능을 설정해 주시기 바랍니다.</dd>
</dl>
<!--[e] Tip -->
</div>